<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <script type="text/javascript" src="js/jquery-1.12.4.js"></script>
    <script type="text/javascript">
        $(function () {
            var $div = $('.box');
            /* var oPos = $div.offset(); //获取div的位置 */

            $div.click(function () {
                var oPos = $div.offset();

                document.title = oPos.left + " | " + oPos.top;

                //alert(oPos.left);
            });

            //console.log(oPos);



        });
    </script>
    <style type="text/css">
        .box {
            width: 200px;
            height: 200px;
            background-color: gold;
            margin: 50px auto 0;
        }
    </style>
    <title>Document</title>
</head>

<body>
    <div class="box"></div>

</body>

</html>